package handlers

import (
	"fmt"
	"math/rand"
	"regexp"
	"time"
)

// IsVaildMobile 判断手机号格式
func IsVaildMobile(mobile string) bool {
	reg := `^1([38][0-9]|14[57]|5[^4])\d{8}$`
	rgx := regexp.MustCompile(reg)
	return rgx.MatchString(mobile)
}

// GenCode 生成6位数随机验证码
func GenCode() string {
	rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
	code := fmt.Sprintf("%06v", rnd.Int31n(1000000))
	return code
}
